using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Reflection;

namespace moDb_prototype.Serialization
{
    public abstract class BinarySerializer<T>
    {
        protected PropertyInfo[] propertiesToSerialize()
        {            
            return Reflector.ReflectedProperties(objectToSerialize);
        }
        public BinarySerializer(T objectToSerialize)
        {
            if (objectToSerialize == null)
            {
                throw new NullReferenceException("Object to serialize cannot be null.");
            }
            else
                this.objectToSerialize = objectToSerialize;
        }
        #region IBinarySerializer Members
        protected T objectToSerialize;
        /// <summary>
        /// Gets the object to serialize.
        /// </summary>
        /// <value>The object to serialize.</value>
        public T ObjectToSerialize
        {
            get
            {
                return objectToSerialize;
            }
        }

        /// <summary>
        /// Reads the serialized record from a BinaryReader.
        /// </summary>
        /// <param name="reader">The reader.</param>
        public abstract void Read(BinaryReader reader);

        /// <summary>
        /// Writes the serialized record to a BinaryWriter.
        /// </summary>
        /// <param name="reader">The reader.</param>
        public abstract void Write(BinaryWriter writer);
        

        #endregion   
    }
}
